package org.vectrics.mail;

import java.util.Locale;

import org.vectrics.common.html.BorderTable;
import org.vectrics.common.html.Cell;
import org.vectrics.common.html.Row;
import org.vectrics.common.html.Table;
import org.vectrics.provider.CoreServiceLocator;

public class EmailTable extends BorderTable {
	private Locale locale = null;
	public EmailTable(Locale locale) {
		super();
		this.locale = locale;
	}
	
	
	public Locale getLocale() {
		return(this.locale);
	}
	
	public String getPhrase(String code) {
		return CoreServiceLocator.getPhraseProvider().getMessage(code, locale);
	}


	public void addProperyRow(String caption, String value) {
		appendPropertyRow(caption, value, this);
	}
	
	public static void appendPropertyRow(String caption, String value, Table table) {
		
		String captionBackground = "#c0c0f0";
		String valueBackground = "#f0f0ff";
		Row row;
		Cell cell;
		
		row = table.addRow();
		cell = row.addCell();
		cell.setBgColor(captionBackground);
		cell.addElement("<font style=\"font:bold 0.7em Verdana\">" + caption + "</font>");
		cell = row.addCell();
		cell.setBgColor(valueBackground);
		String displayValue = value;
		if (displayValue == null) {
			displayValue = "&nbsp;";
		}
		cell.addElement("<font style=\"font:normal 0.7em Verdana\">" + displayValue + "</font>");
	}
	
}
